package com.ruoyi.stuclient.service.impl;


import com.github.yulichang.base.MPJBaseServiceImpl;
import com.ruoyi.common.core.context.ThirdSessionHolder;
import com.ruoyi.stuclient.domain.EwcRaiseHand;
import com.ruoyi.stuclient.domain.dto.ChapterRaiseHandDto;
import com.ruoyi.stuclient.mapper.EwcRaiseHandMapper;
import com.ruoyi.stuclient.service.IEwcRaiseHandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.UUID;


/**
 * 学生举手记录Service业务层处理
 * 
 * @author zsp
 * @date 2025-06-02
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class EwcRaiseHandServiceImpl extends MPJBaseServiceImpl<EwcRaiseHandMapper, EwcRaiseHand> implements IEwcRaiseHandService {

    @Autowired
    private  EwcRaiseHandMapper ewcRaiseHandMapper;

    /**
     * 保存举手记录信息
     * @param chapterRaiseHandDto
     */
    @Override
    public void saveRaiseRecord(ChapterRaiseHandDto chapterRaiseHandDto) {
        EwcRaiseHand ewcRaiseHand = new EwcRaiseHand();
        String flowId = UUID.randomUUID().toString().replace("-", "");
        Date currentDate = new Date();
        ewcRaiseHand.setId(flowId);
        ewcRaiseHand.setClassId(chapterRaiseHandDto.getClassId());
        ewcRaiseHand.setCourseId(chapterRaiseHandDto.getCourseId());
        ewcRaiseHand.setChapterId(chapterRaiseHandDto.getId());
        ewcRaiseHand.setStudentId(ThirdSessionHolder.getThirdSession().getId());
        ewcRaiseHand.setTeacherId(chapterRaiseHandDto.getTeacherId());
        ewcRaiseHand.setCreateTime(currentDate);
        this.save(ewcRaiseHand);
    }
}
